<script>
export default {
  name: 'StatusBadge',
  functional: true,
  props: {
    status: {
      type: Number,
      required: true,
      validator(value) {
        return [0, 1, 2].indexOf(value) >= 0
      }
    }
  },
  render(h, context) {
    const textMap = {
      0: '未审核',
      1: '通过',
      2: '不通过'
    }
    const colorMap = {
      0: 'primary',
      1: 'success',
      2: 'error'
    }
    const status = context.props.status
    const content = textMap[status] || '未知状态'
    const color = colorMap[status] || 'grey400'
    return h('mu-badge', { props: { content, color } })
  }
}
</script>
